package com.wanhe.base.util;

import android.text.TextUtils;

import java.text.DecimalFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by XieZaiWei on 2017/5/9.
 */

public class NumberUtil {

	public static boolean checkPhoneNumber(String phone){
		if (TextUtils.isEmpty(phone)) {
			return false;
		}
		Pattern p = Pattern.compile("^(1)\\d{10}$");
		Matcher m = p.matcher(phone);
		boolean find = m.find();
		if (!find){
			return false;
		}
		return true;
	}

	public static String transNumberToDot(double number){
		DecimalFormat df = new DecimalFormat("#,###.##");
		return df.format(number);
	}

	/**
	 * 转成不带小数点的double类型
	 * @param number
	 * @return
	 */
	public static String doubleNotDot(double number){
		DecimalFormat df = new DecimalFormat("#");
		return df.format(number);
	}
}
